package learn_concurrent._7;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class T2 {
	static final Logger logger = LoggerFactory.getLogger(T2.class);
	
	static volatile int count = 10;
	static final Object lock = new Object();

	public static void main(String[] args) throws InterruptedException {
		new Thread(() -> {
			while(count > 0) {
				try {
					Thread.sleep(200);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				count--;
				logger.info("count = {}", count);
			}
		}, "t1").start();
		
		new Thread(() -> {
			while(count < 20) {
				try {
					Thread.sleep(200);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				count++;
				logger.info("count = {}", count);
			}
		}, "t2").start();
	}

}
